using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GameFramework;

namespace LS
{
    [Serializable]
    public class DataParamsBase : IReference
    {
        /// <summary>
        /// 用户自定义数据。
        /// </summary>
        public object UserData
        {
            get;
            set;
        }

        public DataParamsBase() { }

        public static T Create<T>()
            where T : DataParamsBase
        {
            return (T)ReferencePool.Acquire(typeof(T));
        }

        public static T Create<T>(object userData)
            where T : DataParamsBase
        {
            var par = (T)ReferencePool.Acquire(typeof(T));
            par.UserData = userData;
            return par;
        }

        public static void Release<T>(T dataParams) where T : DataParamsBase
        {
            ReferencePool.Release(dataParams);
        }

        public void Release()
        {
            Release(this);
        }

        public virtual void Clear()
        {
            UserData = null;
        }
    }
}
